﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="../style.css">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>

<form action="liga_anlegen_v2.php" method="post">

<?php

	include("../inc/joomlaInt_admin.php");
	include("../inc/inc_configuration.php");

	
if ($jUser==0)
{
	echo "Bitte zuerst einloggen!";
}
else
{
	
	$q="SELECT gid FROM $tbl_users WHERE id=$jUser";
					$qe=mysql_query($q);
					$qeo=mysql_fetch_object($qe);
					
					$gid=$qeo->gid;
					
					if ($gid!=$admingroup)
					{
						echo "Du bist kein Admin!";
						break;
					}
					
	$name=$_POST["name"];
	$teamAnz=$_POST["teamAnz"];
	$type=$_POST["type"];
	$pic=$_POST["pic"];
	
	if ($type>1)
	{
		$season=$_SESSION["season"];
	
		$q = "INSERT INTO $tbl_leagues (name,land,seasonId,type,picId) VALUES (";
		$q.="'$name',1,$season,$type,$pic)";
		$qe=mysql_query($q);
		echo'Sie werden weitergeleitet... <meta http-equiv="refresh" content="0; URL=saison_verwaltung.php">';
	}
	else
	{
		echo '<input hidden type="text" size="17" name="name" value="',$name,'">';
		echo '<input hidden type="text" size="17" name="teamAnz" value="',$teamAnz,'">';
		echo '<input hidden type="text" size="17" name="type" value="',$type,'">';
		echo '<input hidden type="text" size="17" name="pic" value="',$pic,'">';
		
		// $q = "INSERT INTO $tbl_slt (yearB, yearE, number, active) VALUES ($yearB, $yearE, $number, 1)";
		// $qe = mysql_query($q);
		
		echo "<table class='nb'>";
		$count = 1;
		while($count <= $teamAnz)
		{
		
			$abfrage = "SELECT * FROM $tbl_teams ORDER BY name"; 
			$ergebnis = mysql_query($abfrage);
			
			echo '<tr>
					<td>Team ',$count,'</td>
					<td><select name="team',$count,'" Size="1">';
			
			while ($row = mysql_fetch_object($ergebnis))
				{
					echo '<Option Value="',$row->id,'">' ,$row->name, '</option>';
				}
				
			echo"</select></td></tr>";
			$count++;
		}
		
		
		echo"</table>";
	}
	
		echo '<input type="submit" class="button eintragen" value="OK">';
}	
	
	

?>


<br><br>
<center><a href='javascript:window.history.back()' class='button zurueck'>Zurück</a></center>

</body>
</html>